154 PART 4 Comparing Groups
criterion than only having to be less than 0.05). Even though the Bonferroni
adjustment is easy to do by hand, because most analysts use statistical
packages when doing these calculations, it is not used very often in practice.»
» Tukey’s HSD (“honestly” significant difference) test adjusts α in a different
way than Bonferroni. It is intended to be used when there are equally-sized
groups in each level of the variable (also called balanced groups).»
» The Tukey-Kramer test is a generalization of the original Tukey’s HSD test
to designed to handle different-sized (also called unbalanced) groups. Since
Tukey-Kramer also handles balanced groups, in R statistical software, only
the Tukey-Kramer test is available, and not Tukey’s HSD test (as demon-
strated later in this chapter in the section “Executing and interpreting
post-hoc t tests”).»
» Scheffe’s test compares all pairs of groups, but also lets you bundle certain
groups together if doing so makes physical sense. For example, if you have
two treatment groups and a control group (such as Drug A, Drug B, and
Control), you may want to determine whether either drug is different from the
control. In other words, you may want to test Drug A and Drug B as one group
against the control group, in which case you use Scheffe’s test. Scheffe’s test is
the safest to use if you are worried your analysis may be suffering from Type I
error because it is the most conservative. On the other hand, it is less
powerful than the other tests, meaning it will miss a real difference in your
data more often than the other tests.
Running an ANOVA
Running a one-way ANOVA in R is similar to running an independent t test (see
the earlier section “Executing a t test”). However, in this case, we save the results
as an object, and then run R code on that object to get the output of our results.
Let’s turn back to the NHANES data. First, we need to prepare our grouping vari-
able, which is the three-level variable MARITAL (where 1 = married, 2 = never mar-
ried, and 3 = all over marital statuses). Next, we identify our dependent variable,
which is our fasting glucose variable called LBXGLU. Finally, we employ the aov
command to run the ANOVA in R, and save the results in an object called
GLUCOSE_aov. We use the following code: GLUCOSE_aov <- aov(LBXGLU ~
as.factor(MARITAL), data = NHANES). (The reason we have to use the as.factor com-
mand on the MARITAL variable is to make R handle it as an ordinal variable in the
calculation, not a numeric one.) Next, we can get our output by running a summary
command on this object using this code: summary(GLUCOSE_aov).